package com.tiger.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.tiger.mapper.base.BlinkMapper;
import com.tiger.mapper.homePage.HomePageBlinkCardsMapper;
import com.tiger.pojo.base.Blink;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

/**
 * @author HuXuehao (StudiousTiger)
 * @desc 这个类的作用是
 * @date 2022/2/9
 */
@Slf4j
@RestController
public class BlinkController {
    @Autowired
    private BlinkMapper blinkMapper;

    /**
     * 删除Blink
     * @param blinkId
     * @param likeCount
     * @return
     */
    @RequestMapping(value = "/blink/addLike/{blinkId}/{likeCount}", name = "删除Blink/user")
    public String addLike(@PathVariable String blinkId, @PathVariable String likeCount){
        try {
            UpdateWrapper<Blink> wrapper = new UpdateWrapper<>();
            wrapper.eq("blink_id",blinkId);
            wrapper.set("blink_like",likeCount);
            int res = blinkMapper.update(null, wrapper);
            if (res == 1) {
                return "true";
            } else {
                return "false";
            }
        } catch (Exception e) {
            log.error(e.toString());
            return "false";
        }
    }

}
